package com.ocean.core.util.constants;

import com.ocean.core.util.SpringContextUtil;
import com.ocean.core.util.constants.properties.ProjectProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;

/**
 * 缓存常量池
 *
 * @author zhang
 * @since 2020-12-10
 */
public class ConstantsCache {

    /**
     * 项目名
     */
    private final String project;

    /**
     * token
     */
    private final String authenticationPrefix;

    @Autowired
    public ConstantsCache(ProjectProperties projectProperties) {
        this.project = projectProperties.getName();
        this.authenticationPrefix = this.project + "authorization:";
    }

    public String getProject() {
        return project;
    }


    public String getAuthenticationPrefix() {
        return authenticationPrefix;
    }

    public static ConstantsCache getInstance() {
        ApplicationContext context = SpringContextUtil.getApplicationContext();
        return context.getBean(ConstantsCache.class);
    }
}
